package com.cn.test;


import com.cn.dao.BookDao;
import com.cn.dao.BookDaoTwo;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class LifeStyleTest1 {
    /**
     * 5.1.1 init、destroy
     */
    @Test
    public void test1(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        BookDao bookDao = context.getBean("bookDao", BookDao.class);
        bookDao.save();
        //context.close();
        context.registerShutdownHook();
    }

    @Test
    public void test2(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        BookDaoTwo bookDaoTwo = context.getBean("bookDaoTwo", BookDaoTwo.class);
        context.close();
    }


}
